
BOOST_INC=/usr/local/include/boost-1_39

TEST_TARGETS= attributes_test date_time_test expat_parser_test \
	gpx_parser_test gps_proto_util_test tcx_parser_test

OBJS= attributes.o date_time.o gpx_parser.o tcx_parser.o gps_parser.o \
	expat_parser.o string_util.o gps.pb.o gps_proto_util.o

# TODO: this is specific to MacOSX
LIB= libgpb.dylib

all: test ${LIB}

test: ${TEST_TARGETS}
	./attributes_test
	./date_time_test
	./expat_parser_test
	./gps_proto_util_test
	./gpx_parser_test
	./tcx_parser_test

gps.pb.o: ../proto/gps.pb.cc
	g++ -c $<

attributes.o: attributes.cc attributes.h
	g++ -c $< -I${BOOST_INC} -I/usr/local/include

date_time.o: date_time.cc date_time.h
	g++ -c $< -I${BOOST_INC} -I/usr/local/include

expat_parser.o: expat_parser.cc expat_parser.h expat_handler.h
	g++ -c $<

gps_parser.o: gps_parser.cc
	g++ -c $< -I${BOOST_INC} -I../proto

gpx_parser.o: gpx_parser.cc gps_parser.h gpx_parser.h ../proto/gps.pb.h
	g++ -c $< -I../proto -I${BOOST_INC} -I/usr/local/include

gps_proto_util.o: gps_proto_util.cc gps_proto_util.h
	g++ -c $< -I../proto

attributes_test: attributes_test.cc attributes.o string_util.o
	g++ -o $@ attributes_test.cc attributes.o string_util.o -I${BOOST_INC} -I/usr/local/include -L/usr/local/lib -lgtest

date_time_test: date_time_test.cc date_time.o
	g++ -o $@ date_time_test.cc date_time.o -I${BOOST_INC} -L/usr/local/lib -lgtest

expat_parser_test: expat_parser_test.cc expat_parser.o
	g++ -o $@ expat_parser_test.cc expat_parser.o -I${BOOST_INC} -I/usr/local/include -L/usr/local/lib -lprotobuf -lgtest -lexpat

gps_proto_util_test: gps_proto_util_test.cc gps_proto_util.o
	g++ -o $@ gps_proto_util_test.cc gps_proto_util.o ../proto/gps.pb.cc -I../proto -L/usr/local/lib -lprotobuf -lgtest -lkmlbase

gpx_parser_test: gpx_parser_test.cc gpx_parser.o gps_parser.o expat_parser.o ../proto/gps.pb.cc string_util.o attributes.o date_time.o
	g++ -o $@ gpx_parser_test.cc ../proto/gps.pb.cc gpx_parser.o gps_parser.o expat_parser.o attributes.o string_util.o date_time.o -I../proto -I${BOOST_INC} -I/usr/local/include -L/usr/local/lib -lprotobuf -lgtest -lexpat -lglog

tcx_parser.o: tcx_parser.cc tcx_parser.h ../proto/gps.pb.h
	g++ -c $< -I../proto -I${BOOST_INC} -I/usr/local/include

tcx_parser_test: tcx_parser_test.cc tcx_parser.o gps_parser.o expat_parser.o ../proto/gps.pb.cc
	g++ -o $@ tcx_parser_test.cc tcx_parser.o gps_parser.o ../proto/gps.pb.cc expat_parser.o attributes.o string_util.o date_time.o -I../proto -I${BOOST_INC} -I/usr/local/include -L/usr/local/lib -lprotobuf -lgtest -lexpat -lglog

libgpb.dylib: ${OBJS}
	g++ -dynamiclib -o $@ ${OBJS} -lprotobuf -lglog -lexpat -lkmlbase -lstdc++.6

clean:
	rm -f ${LIB} ${TEST_TARGETS} *.o
